﻿using GXWA_DATA.Model.ConfigModel;
using GXWA_DATA.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GXWA_DATA.Model.Singleton
{
    public sealed class PlcConfigModelSingleton
    {
        private static readonly Lazy<List<PlcConfigModel>> _instance = new Lazy<List<PlcConfigModel>>(() => new List<PlcConfigModel>());

        public static List<PlcConfigModel> Instance => _instance.Value;

        public PlcConfigModelSingleton() { }

        /// <summary>
        /// 添加PLC配置
        /// </summary>
        /// <param name="plcConfigModel"></param>
        public static void Add(PlcConfigModel plcConfigModel)
        {
            Instance.Add(plcConfigModel);

            Tools.ProduceLogText($"[{plcConfigModel.Config.Nick}]配置成功，IP为[{plcConfigModel.Config.Ip}]，当前缓存[{Instance.Count}]");
        }
    }
}
